Mac 本地搭建服务器实现itms-services方式安装ipa(自制证书)

1.前言

没有服务器,没有https(>=iOS7)。只有一个联网的mbp(OS X EI 10.11.6)。how?

还记得“火星救援么”:遇到一个问题解决一个问题,解决了做够多的问题后,就可以回家了。

2.解决问题

首先需要一个本地的https服务器:服务器搭建

其次需要一个plist(名字随意settings.plist),贴上一份:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://192.168.3.186/codesigndemo.ipa</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>https://192.168.3.186/icon.png</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>https://192.168.3.186/display.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>你的bundleid</string>
<key>bundle-version</key>
<string>***</string>
<key>kind</key>
<string>software</string>
<key>subtitle</key>
<string>好买手</string>
<key>title</key>
<string>好买手</string>
</dict>
</dict>
</array>
</dict>
</plist>

该换的地方换成自己的

再来份html如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>应用</title>
</head>
<body>
<h1 style="font-size:40pt">iOS应用安装<h1/>
<h1 style="font-size:40pt">
<a href='itms-services://?action=download-manifest&url=https://192.168.3.186/settings.plist'>Iphone Download</a>
<h1/>
<a title="iPhone" href="http://192.168.3.186/localhost.crt">ssl localhost 证书安装</a>
<a title="iPhone" href="http://192.168.3.186/server.crt">ssl server 证书安装</a>
<h1/>
</body>
</html>

由于证书是自己制作的,需要设备安装正式添加信任

最后,把plist、html、ipa还有两个证书放在服务器根目录。手机和服务器在一个局域网内,手机浏览,先安装证书,在安装ipa。